DScaler Video Deinterlace (Weave) Method
á

This was one of the earliest video deinterlace methods. It used three fields in the calculation and works well on slow moving material but tends to comb on fast moving material.

Comments from code


For ease of reading, the comments below assume that we're operating on an odd
field (i.e., that bIsOdd is true).  The exact same processing is done when we
operate on an even field, but the roles of the odd and even fields are reversed.
It's just too cumbersome to explain the algorithm in terms of "the next odd
line if we're doing an odd field, or the next even line if we're doing an
even field" etc.  So wherever you see "odd" or "even" below, keep in mind that
half the time this function is called, those words' meanings will invert.

Copy the even scanline below this one to the overlay buffer, since we'll be
adapting the current scanline to the even lines surrounding it.  The scanline
above has already been copied by the previous pass through the loop.

The meat of the work is done here.  We want to see whether this pixel is
close in luminosity to ANY of: its top neighbor, its bottom neighbor,
or its predecessor.  To do this without branching, we use MMX's
saturation feature, which gives us Z(x) = x if x>=0, or 0 if x<0.

The formula we're computing here is
     Z(ST - (E1 - O) ^ 2) + Z(ST - (E2 - O) ^ 2) + Z(TT - (Oold - O) ^ 2)
where ST is spatial tolerance and TT is temporal tolerance.  The idea
is that if a pixel is similar to none of its neighbors, the resulting
value will be pretty low, probably zero.  A high value therefore indicates
that the pixel had a similar neighbor.  The pixel in the same position
in the field before last (Oold) is considered a neighbor since we want
to be able to display 1-pixel-high horizontal lines.

Now compare the similarity totals against our threshold.  The pcmpgtw
instruction will populate the target register with a bunch of mask bits,
filling words where the comparison is true with 1s and ones where it's
false with 0s.  A few ANDs and NOTs and an OR later, we have bobbed
values for pixels under the similarity threshold and weaved ones for
pixels over the threshold.
Setting Default Description
Temporal Tolerance 300 ???
Spatial Tolerance 600 ???
Similarity Threshold 25 ???
á
á